import sys
import time


def compute(n):
    if not n.isdigit():
        print('"', n, '"', "Is not a integer number!")
        return
    n = int(n)
    w = n + 10
    b = 10 ** w
    x1 = b * 4 // 5
    x2 = b // -239
    he = x1 + x2
    n *= 2
    for i in range(3, n, 2):
        x1 //= -25
        x2 //= -57121
        x = (x1 + x2) // i
        he += x
    pai = he * 4
    pai //= 10 ** 10
    pi = str(pai)
    pi = pi[:1] + '.' + pi[1:]
    print(pi)


def show_help():
    print("Usage: picalc [OPTIONS] [LENGTH]")
    print("    -h or --help   show this help and exit")
    print("    --wiz          Wizard mode")
    print("    --time         Timing mode(--wiz will overwrite this!!)")
    print("[LENGTH] is the length of the calculate scale")


if __name__ == '__main__':
    if len(sys.argv) == 1:
        print("No argument inputted, print the help and exit")
        print()
        show_help()
    elif "-h" in sys.argv or "--help" in sys.argv:
        show_help()
    elif "--wiz" in sys.argv:
        while "true":
            compute(input("Input the calculating scale: "))
            ans = input("Calculate again?[Y/n]")

            if ans == "Y" or ans == "" or ans == "y":
                pass
            else:
                print("Abort.")
                break
    elif "--time" in sys.argv:
        start_time = time.time()
        compute(sys.argv[2])
        print()
        print("Time usage:", time.time() - start_time, "seconds")
    else:
        compute(sys.argv[1])
